package cn.maszy.action.investment;

import org.springframework.beans.factory.annotation.Autowired;

import net.sourceforge.stripes.action.SessionScope;
import cn.maszy.common.BaseAction;
import cn.maszy.common.Pager;
import cn.maszy.model.investment.B_T_Ufp_Department;
import cn.maszy.service.investment.B_T_Ufp_DepartmentService;


@SessionScope
public class DepartmentAction extends BaseAction<B_T_Ufp_Department> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2475349243064011153L;
	private B_T_Ufp_Department b_T_Ufp_Department;
	@Autowired
	private B_T_Ufp_DepartmentService b_T_Ufp_DepartmentService;
	private String checkIds;
	
	/*********************class set/get****************************/
	public String getCheckIds() {
		return checkIds;
	}
	public void setCheckIds(String checkIds) {
		this.checkIds = checkIds;
	}
	public B_T_Ufp_Department getB_T_Ufp_Department() {
		return b_T_Ufp_Department;
	}
	public void setB_T_Ufp_Department(B_T_Ufp_Department b_T_Ufp_Department) {
		this.b_T_Ufp_Department = b_T_Ufp_Department;
	}
	
	/*******************STRUTS ACTION METHOD*************************/
	public String departmentCallback() throws Exception{
		pager = new Pager<B_T_Ufp_Department>(pageNum, numPerPage,orderField,orderDirection);
		pager= b_T_Ufp_DepartmentService.selectList(b_T_Ufp_Department,pager);
		return SUCCESS;
	}
	/**
	 * 页面查询
	 * @return
	 * @throws Exception
	 */
	public String departmentList() throws Exception {
		pager = new Pager<B_T_Ufp_Department>(pageNum, numPerPage,orderField,orderDirection);
		pager= b_T_Ufp_DepartmentService.selectList(b_T_Ufp_Department,pager);
		return SUCCESS;
	}
	/**
	 * 新增更新
	 * @return
	 * @throws Exception
	 */
	public String departmentUpdate() throws Exception {
		int i	=b_T_Ufp_DepartmentService.update(b_T_Ufp_Department);
		if(i>0)
			//目前只有点击提交后关闭
			//return ajaxForwardSuccess(getText("msg.operation.success"), "adminList", "closeCurrent", "investment/adminList");
		//保存不关闭暂时没做
		return ajaxForwardSuccess(getText("msg.operation.success"), "DepartmentList","", "forward", "investment/DepartmentList");
		return ajaxForwardError(getText("msg.operation.failure"));
	}

	/**
	 * 页面跳转
	 * @return
	 * @throws Exception
	 */
	public String departmentJump() throws Exception {
		return SUCCESS;
	}
	/**
	 * 删除一条数据
	 * @return
	 * @throws Exception
	 */
	public String departmentDel() throws Exception {
		int i=b_T_Ufp_DepartmentService.delete(checkIds);
		if(i>0)
		return ajaxForwardSuccess(getText("msg.operation.success"), "DepartmentList","", "forward", "investment/DepartmentList");
		return ajaxForwardError(getText("msg.operation.failure"));
	}
	/**
	 * 查询一条数据
	 * @return
	 * @throws Exception
	 */
	public String departmentDetail() throws Exception {
		if(b_T_Ufp_Department==null){
			b_T_Ufp_Department=b_T_Ufp_DepartmentService.selectOne("");
		}else{
			b_T_Ufp_Department=b_T_Ufp_DepartmentService.selectOne(b_T_Ufp_Department.getUuid());
		}
		return SUCCESS;
	}
}
